<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>时段护理卡模板管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		global.loginPassword = "${fns:getLoginPw()}";
		$(document).ready(function() {
			$("#contentTable tbody tr").click(function(){
				sessionStorage.parentPageNo = $("#pageNo").val();
				sessionStorage.parentSelect = this.id;
				var item = $("#opreation-"+ this.id);
				if(item.length > 0) {
					item.remove();
					return;
				}
				$(".opreationTR").removeClass("opreationTR");
				$(".opreation").remove();
				var html= '<tr id="opreation-' + this.id + '" class="opreation"><td colspan="5">';
				if($(this).attr("status") == "0"){
					html += '<a data-role="button" data-inline="true" href="${ctx}/base/storeCardTemplateDuration/form?id='+this.id+'">修改</a>'+
					'<a data-role="button" data-inline="true" href="${ctx}/base/storeCardTemplateDuration/delete?id='+this.id+'" onclick="return confirmx("确认要停用该时段护理卡模板吗？", this.href)">停用</a>'+
					"</td></tr>";
				} else {
					html += '<a data-role="button" data-inline="true" href="${ctx}/base/storeCardTemplateDuration/delete?id='+this.id+'" onclick="return confirmx("确认要启用该时段护理卡模板吗？", this.href)">启用</a>'+
					"</td></tr>";
				}
				$(this).after(html);
				$(this).addClass("opreationTR");
				$("#contentTable").trigger('create');
			});
			var currentSelectId = '${currentSelectId}';
			if(currentSelectId){
				$("#"+currentSelectId).addClass("opreationTR");
			} else {
				$("#contentTable tbody tr:first-child").addClass("opreationTR");
			}
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<div class="icon-buttons">
		<a data-role="button" data-inline="true" data-icon="back" data-iconpos="notext"  href="${ctx}">返回</a>
	</div>
	<nav data-role="navbar">
	    <ul>
	        <li><a href="${ctx}/base/storeCardTemplateTimes/">计次护理卡模板</a></li>
	        <li><a href="${ctx}/base/storeCardTemplateDuration/" class="ui-btn-active">时段护理卡模板</a></li>
	        <li><a href="${ctx}/base/storeCardTemplateProduct/">产品充值卡模板</a></li>
	        <li><a href="${ctx}/base/storeCardTemplateAll/">综合充值卡模板</a></li>
	    </ul>
	</nav>
	<form:form id="searchForm" modelAttribute="storeCardTemplateDuration" action="${ctx}/base/storeCardTemplateDuration/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input type="button" value="新增会员卡模板" data-inline="true" onclick="loginPasswordPopup('${ctx}/base/storeCardTemplateDuration/form')">
		<fieldset data-role="controlgroup" data-type="horizontal" data-inline="true">
	        <input type="radio" name="searchStatus" id="radio-choice-a" value="0" ${empty searchStatus || searchStatus == '0' ? 'checked' : ''}>
	        <label for="radio-choice-a">有效会员卡模板</label>
	        <input type="radio" name="searchStatus" id="radio-choice-b" value="1" ${searchStatus == '1' ? 'checked' : ''}>
	        <label for="radio-choice-b">无效会员卡模板</label>
		</fieldset> 
		<input id="btnSubmit" type="submit" value="查询" data-inline="true"/>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" data-role="table" class="ui-responsive table-stroke">
		<thead><tr><th>卡名</th><th>护理项目</th><th>护理时段</th><th>新卡内置金额</th><th>开卡优惠价</th></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="storeCardTemplateDuration">
			<tr id="${storeCardTemplateDuration.id}" status="${storeCardTemplateDuration.status}">
				<td>${storeCardTemplateDuration.name}</td>
				<td>${storeCardTemplateDuration.storeCare.care_type == 0? storeCardTemplateDuration.storeCare.care.name : storeCardTemplateDuration.storeCare.storeSelfCare.name}</td>
				<td>${storeCardTemplateDuration.duration}月</td>
				<td>${storeCardTemplateDuration.retail_price}元</td>
				<td>${storeCardTemplateDuration.real_cost}元</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>
